﻿using FMAPortalBase.Enum;
using FMAPortalBase.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace FMAPortal.Controllers
{
    public class WebController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            RouteData route = this.RouteData;
            //String template = route.Values["template"].ToString();
            String page = route.Values["page"].ToString();
             String parameter = null;
            if (route.Values["p"] != null)
            {
                parameter = route.Values["p"].ToString();
                
            }
            return View();
        }
        public ActionResult Admin()
        {
            RouteData route = this.RouteData;
            String parameter = null;
            if (route.Values["p"] != null)
            {
                parameter = route.Values["p"].ToString();
                if (System.IO.File.Exists(Server.MapPath("/Views/Web/admin/" + parameter + ".cshtml")))
                {
                    return View("admin/" + parameter);
                }
                else 
                    return View("admin/home");
            }
            else
                return View("admin/home");
        }

    }
}